<!--
 * @Date: 2022-03-01 09:27:41
 * @Author: 陶子
 * @LastEditTime: 2023-06-25 16:31:16
 * @FilePath: \jk_one-stop_pc\src\views\qualityManagement\qualityRecord\qualityRecordList.vue
 * @pageName: 这是--(质检记录)--页面
-->
<template>
  <div class="pagebox">
    <crumbs @goBack="()=>{}" :superiorMenu="['质量管理']" currentMenu="质检记录" style="margin-bottom:12px"></crumbs>
    <a-card :bordered="false" size="small" style="height:100%">
      <div class="topBox">
        <div>
          <a-button @click="handleShowFilter" icon="filter" style="margin-right: 10px"> 筛选 <span style="color:#1890FF;margin-left:5px">{{realFilterNum}}</span></a-button>
          <a-button @click="showColumn" icon="unordered-list" style="margin-right: 10px"> 设置列 </a-button>
        </div>
        <div class="right-btn">
          <PubExport :exportUrl='exportUrl' :columns="columns" :propForm='formatData("export")' :selectedRows='chooseArr' :sortForm='sortForm' :fullName='fullName' />
          <a-button type="primary" style="margin-left: 10px" @click="newBuild"> 质检报工 </a-button>
        </div>
      </div>
      <!-- :row-selection="{ selectedRowKeys: selectedRowKeys,columnTitle:' ',columnWidth:35, onChange: onSelectChange,}" -->
      <a-table :key="tableKey" row-key="id" :row-selection="{ selectedRowKeys: selectedRowKeys,columnTitle:' ',columnWidth:35, onChange: onSelectChange,}" :columns="columns" :data-source="tableData" :pagination="false" :scroll="{ x: computedX,y:'calc(100vh - 366px)' }" @change="tableChange" :components="drag(columns, 'QUALITY_RECORD_LIST')">
        <!-- 输入框搜索 -->
        <div slot="searchDropdown" slot-scope="{confirm, clearFilters, column }" class='searchWorkOreder'>
          <a-input :placeholder='checkPlaceholder(column.dataIndex)' v-model="tableFilterForm[column.dataIndex]" style="width: 188px;display: block;" />
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => pubSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="searchIcon" slot-scope="filtered" type="search" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 选择搜索 -->
        <div slot="selectDropdown" slot-scope="{confirm, clearFilters, column}" class='searchWorkOreder'>
          <a-select mode="multiple" allowClear :placeholder="checkPlaceholder(column.dataIndex)" style="width: 200px" v-model="tableFilterForm[column.searchKey]">
            <a-select-option v-for="option in processList" :key="option.value" :value="option.value">{{
              option.name
            }}</a-select-option>
          </a-select>
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => pubSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="selectIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 人员选择 -->
        <div slot="selectPeople" slot-scope="{confirm, clearFilters, column }" class='searchWorkOreder'>
          <j-select-user-by-dep @changeRow="userOperator" v-model="operatorStr" :seldep='true' :modalWidth="1000" :limit="5" :multi="true"
            v-if="column.dataIndex=='operatorName'">
          </j-select-user-by-dep>
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="peopleIcon" slot-scope="filtered" type="search" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 插槽显示 -->
        <span slot="goodsName" slot-scope="text,record" :title="record.goodsName">{{ record.goodsName }}</span>
        <span slot="processName" slot-scope="text,record" :title="record.processName">{{ record.processName }}</span>
        <span slot="processRequire" slot-scope="text,record" :title="record.processRequire">{{ record.processRequire  }}</span>
        <span slot="qualifiedNum" slot-scope="text,record">{{numFormat(record.qualifiedNum)|| '0' }}</span>
        <span slot="notQualifiedNum" slot-scope="text,record">{{numFormat(record.notQualifiedNum) || '0'}}</span>
        <span slot="planEndTime" slot-scope="text,record">{{record.planEndTime ? moment(record.planEndTime).format('YYYY-MM-DD HH:mm') : '-'}}</span>
        <span slot="planStartTime" slot-scope="text,record">{{record.planStartTime ? moment(record.planStartTime).format('YYYY-MM-DD HH:mm') : '-'}}</span>
        <span slot="orderCode" @click='openDetail(record)' slot-scope="text,record" style="color:#1890FF;cursor:pointer">{{text ? text : '-'}}</span>
        <div slot="batchCode" slot-scope="text, record" class="btn-text" :title="text" @click="batchRecord(record)">{{text|| '-'}}</div>
        <span slot="statusName" slot-scope="text,record">{{record.statusName ? record.statusName : '-'}}</span>
        <span slot="flowStatusName" slot-scope="text,record" :style="{color: statusColor(record.flowStatus)}">
          <div>{{text || '-' }}</div>
        </span>
        <!-- 操作 -->
        <span slot="actions" slot-scope="text, record">
          <span class='pubColor' @click="goDetail(record)">详情</span>
          <!-- <a-divider v-if="record.flowStatus=='REFUSE'||record.flowStatus=='CANCELED'" type="vertical" />
          <a-popconfirm title="请确定要删除此报工吗?" v-if="record.flowStatus=='REFUSE'||record.flowStatus=='CANCELED'" @confirm="confirmDelete(record)" ok-text="确定" cancel-text="取消">
            <span class='pubColor'>删除</span>
          </a-popconfirm> -->
          <a-divider v-if="record.flowStatus!='RUNNING' || (record.flowStatus=='RUNNING' && record.applicantId == loginUser)" type="vertical" />
          <span class='pubColor' v-if="record.flowStatus=='RUNNING' && record.applicantId == loginUser" @click="handleWithdraw(record)">撤回</span>
          <a-popconfirm title="请确定要删除此报工吗?" v-if="record.flowStatus!='RUNNING'" @confirm="confirmDelete(record)" ok-text="确定"
            cancel-text="取消">
            <span class='pubColor'>删除</span>
          </a-popconfirm>
        </span>
      </a-table>
    </a-card>
    <div class="uni-card resetPadding" :style="{position: 'fixed', bottom:0,right:0,zIndex:2,left:collapsed?'79px':'208px', background: '#fff',paddingLeft:'43px'} ">
      <div style="display: inline-block">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <a-popconfirm title="请确定要批量删除吗?" @confirm="batchAction" ok-text="确定" cancel-text="取消">
          <span class='pubColor' style="margin:0 0px 0 24px">批量删除</span>
        </a-popconfirm>
        <span style="margin-left: 8px">
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }} <span class='pubColor' @click="clearArr" style="margin: 0 10px">清空</span>
        </span>
        <!-- <span>
          {{ `共${total} 条` }}
        </span> -->
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination :total="total" v-model="current" :page-size-options="pageSizeOptions" :page-size="pageSize" @change="onChangePage"
          @showSizeChange="onShowSizeChange" show-quick-jumper show-size-changer />
      </div>
    </div>
    <SetColumn columnName='设置列' ref="SetColumn" v-if="showSetColumn" @sureBtn='sureBtn' @cancelBtn='showSetColumn=false' />
    <!-- 筛选抽屉 -->
    <a-drawer width="500" :closable="true" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">筛选 <span class="filter-num">{{ filteredNums }}</span></div>
        <div class="uni-card" v-if="filteredNums > 0" style="background:#fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="checkShow(item.text)" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float:right" />
            </span>
          </div>
        </div>
        <div style="overflow-y:scroll;flex:1;padding:0">
          <div class="uni-card" style="background:#fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="工单编号">
                <a-input v-model="filterForm.orderCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="批次编号">
                <a-input v-model="filterForm.batchCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="产品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="工序名称">
                <!-- <a-input v-model="filterForm.processName" placeholder="请输入" /> -->
                <a-select
                  mode="multiple"
                  placeholder="请选择"
                  allowClear
                  style="width: 100%"
                  v-model="filterForm['processIds']"
                  @change="(v) => changeSelect(v, 'processIds')"
                >
                  <a-select-option v-for="option in processList" :key="option.value" :value="option.value">{{
                    option.name
                  }}</a-select-option>
                </a-select>
              </a-form-model-item>
              <a-form-model-item label="规格">
                <a-input v-model="filterForm.goodsSpec" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="操作人">
                <j-select-user-by-dep @changeRow="operatorChange" v-model="operatorStr" :seldep='true' :modalWidth="1000" :limit="5" :multi="true"></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="提交时间">
                <a-range-picker date-format="YYYY-MM-DD" :placeholder="['请输入','请输入']" v-model="modelApplyTime" style='width: 100%' @change="timeApplyChange" />
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 批量modal——无法批量 -->
    <a-modal :bodyStyle="{padding:'32px 32px 24px',boxSizing:'border-box'}" :maskClosable='false' v-model="batchOverFiil" :closable="false" on-ok="setLimit"
      width="460px">
      <template slot="footer">
        <a-button key="back" @click='batchOverFiil=false'>
          取消
        </a-button>
        <a-button key="submit" @click='batchOverFiil=false' type="primary">
          确定
        </a-button>
      </template>
      <div class="modalTopBox">
        <a-icon type="close-circle" theme="filled" style="color:red;font-size:22px" />
        <span>无法批量删除</span>
      </div>
      <div class="smallFont">{{resInfo.message}}</div>
    </a-modal>
    <batch-production ref="BatchProduction"></batch-production>
    <windowDetail ref="windowDetail"></windowDetail>
    <qualityDetail ref="qualityDetail"></qualityDetail>
    <windowForm ref="windowForm" @refresh="handleSearch(()=>{})"></windowForm>
  </div>
</template>
<script>
import moment from 'moment'
import { getEnableOne } from '@/api/api'
import { reportApiList, deleteBatch, deleteApi, getProcessList } from '@/api/productOrder'
import { columns, allColumn } from './allColumn.js'
import { getNewColumns, subStrText, numFormat, objArrFilter } from '@/utils/util'
import { API } from '@/api/requestFzs'
import { APILX } from '@/api/requestLx'
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import PubExport from '@/components/pubBtn/PubExport.vue'
import { mapState } from 'vuex'
import tableDragResize from '@/mixins/tableDragResize'
import BatchProduction from '@/pubComponent/BatchProduction'
import windowDetail from '@/views/workManagement/workOrder/workOrderDetail'
import qualityDetail from '@/views/qualityManagement/qualityRecord/qualityDetail'
import windowForm from '@/views/qualityManagement/qualityRecord/buildQuality'
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    align: 'left',
    dataIndex: 'actions',
    ellipsis: true,
    width: 114,
    scopedSlots: { customRender: 'actions' },
  },
]
export default {
  mixins: [tableDragResize],
  components: { crumbs, SetColumn, PubExport, BatchProduction, windowDetail, qualityDetail, windowForm },
  data() {
    return {
      moment,
      numFormat,
      subStrText,
      columns,
      allColumn,
      tableData: [],
      selectedRowKeys: [],
      batchOverFiil: false,
      resInfo: {},
      //全选按钮
      listIndeterminate: false,
      listCheckAll: false,
      current: 1,
      total: 0,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      showSetColumn: false,
      // 抽屉数据
      showFilter: false, // 筛选抽屉
      modelApplyTime: [],
      showOperatorStr: '',
      operatorStr: '',
      realFilterForm: {},
      tableFilterForm: {},
      filterForm: {
        orderCode: '',
        goodsName: '',
        processIds: [],
        operatorIds: '',
        applyTime: [],
      },
      filteredFormLable: {
        orderCode: '工单编号',
        goodsName: '产品名称',
        processIds: '工序名称',
        operatorIds: '操作人',
        applyTime: '提交时间',
        goodsSpec:'规格',
      },
      loginUser: '',
      // 导出参数
      exportUrl: '/mess/messTaskReportWorkApply/exportReportWorkApplyReportXls',
      chooseArr: [],
      sortForm: {},
      allRequestList: [],
      fullName: `质检记录 ${moment(new Date()).format('YYYY-MM-DD HH:mm')}`,
      tableKey: 1.9,
      processList: []
    }
  },
  computed: {
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),
    computedX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width)
      }
      
      return xnum
    },
    realFilterNum() {
      let nums = 0
      for (let key in this.realFilterForm) {
        if (this.realFilterForm[key] != '') {
          nums += 1
        }
      }
      return nums
    },
    filteredNums() {
      let nums = 0
      for (let key in this.filterForm) {
        if (this.filterForm[key] != '') {
          nums += 1
        }
      }
      return nums
    },
    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (this.filteredFormLable[key] == '操作人') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showOperatorStr,
            key,
          })
        } else if (this.filteredFormLable[key] == '工序名称') {
          let strArr = ''
          for (let item of this.filterForm[key]) {
            for (let each of this.processList) {
              if (item == each.value) {
                strArr += each.name + '，'
              }
            }
          }
          strArr = strArr.substring(0, strArr.length - 1)
          list.push({
            title: this.filteredFormLable[key],
            text: strArr,
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
  },
  created() {
    let user = localStorage.getItem('pro__Login_Userinfo')
    this.loginUser = JSON.parse(user).value.id
    let oldValue = localStorage.getItem(this.BUSI_CONST.Entity.QUALITY_RECORD_LIST)
    this.columns = getNewColumns(this.allColumn, JSON.parse(oldValue), actionArr, this.columns)
    getEnableOne({ id: 'MESS_TASK_REPORT_WORK_APPLY_FOR_QUALITY', type: 'add' }).then((res) => {
      if (res.result && res.result == 'false') {
        this.columns = this.columns.filter((item) => item.title != '审核状态')
        this.allColumn = this.allColumn.filter((item) => item.title != '审核状态')
      }
    })
    getProcessList({type: 1}).then((res) => {
      if (res.code == 200) {
        this.processList = res.result
      }
    })
    let obj = {
      pageNo: this.current,
      pageSize: this.pageSize,
    }
    this.getData(obj)
  },
  methods: {
    changeSelect(v, key) {
      if (v.length == 0 || v == '' || v == undefined) {
        // this.filterForm[key] = undefined
        this.filterForm[key] = []
      }
    },
    // 批次生产记录弹窗列表
    batchRecord(record) {
      let obj = {
        id: record.batchId,
        orderId: record.orderId,
        batchCode: record.batchCode,
      }
      this.$refs.BatchProduction.showModal(obj, 'qualityRecordList')
    },
    /* 撤回 */
    handleWithdraw(v) {
      let that = this
      that.$antdConfirm({
        title: '确定撤回吗？',
        content: '撤回后暂不支持再次发起',
        onOk() {
          API.operateRevoke({ flowInstId: v.flowInstId }).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success(res.message)
              let params = that.formatData()
              that.current = 1
              let obj = {
                pageNo: that.current,
                pageSize: that.pageSize,
                ...params,
              }
              that.getData(obj)
            } else {
              that.$antdMessage.error(res.message)
            }
          })
        },
        onCancel() {},
      })
    },
    statusColor(v) {
      let obj = {
        RUNNING: '#1890FF',
        REFUSE: '#FF4D4F',
        TERMINATED: '#888888',
        AGREE: '#00B042',
      }
      return obj[v] || ''
    },
    handleSearch(confirm, dataIndex, clearFilters) {
      confirm() //用来关闭搜索弹窗
      let params = this.formatData()
      this.current = 1
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      this.getData(obj)
    },
    openDetail(row) {
      this.$refs.windowDetail.initDetail({id: row.orderId})
    },
    // 批量删除
    batchAction() {
      if (this.selectedRowKeys.length > 0) {
        let obj = {
          ids: this.selectedRowKeys.join(','),
        }
        deleteBatch(obj).then((res) => {
          if (res.success) {
            let params = this.formatData()
            this.current = 1
            let obj = {
              pageNo: this.current,
              pageSize: this.pageSize,
              ...params,
            }
            this.getData(obj)
            this.selectedRowKeys = []
            this.checkBoxStatus()
            this.$antdMessage.success('批量删除成功!')
          } else {
            this.resInfo = res
            this.batchOverFiil = true
          }
        })
      } else {
        this.$antdMessage.warning('请先选择数据')
      }
    },
    // 操作——详情
    goDetail(row) {
      this.$refs.qualityDetail.initDetail(row.id)
    },
    // 操作——删除
    confirmDelete(row) {
      let obj = {
        id: row.id,
      }
      deleteApi(obj).then((res) => {
        if (res.success) {
          let params = this.formatData()
          if (this.tableData.length === 1) {
            this.current = this.current == 1 ? 1 : this.current - 1
          }
          let obj = {
            pageNo: this.current,
            pageSize: this.pageSize,
            ...params,
          }
          this.getData(obj)
          this.$antdMessage.success('删除成功！')
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
    },
    getData(obj, secondParams) {
      let params = {
        ...obj,
        type: 'quality',
      }
      reportApiList(params).then((res) => {
        if (res.success) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          let copyArr = JSON.parse(JSON.stringify(res.result.records))
          this.tableData = copyArr
          this.allRequestList = this.allRequestList.concat(this.tableData)
          this.allRequestList = objArrFilter(this.allRequestList)
          if (secondParams) {
            this.checkBoxStatus()
          }
        } else {
          this.$antdMessage.warning(res.message)
        }
      })
    },

    /* 打开筛选 */
    handleShowFilter() {
      this.filterForm = JSON.parse(JSON.stringify(this.realFilterForm))
      this.showFilter = true
    },
    newBuild() {
      this.$refs.windowForm.initForm()
    },
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(this.allColumn, this.BUSI_CONST.Entity.QUALITY_RECORD_LIST, columns)
      })
    },
    sureBtn(emitArr) {
      this.columns = getNewColumns(this.allColumn, emitArr, actionArr)
      localStorage.setItem(this.BUSI_CONST.Entity.QUALITY_RECORD_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    checkPlaceholder(dataIndex) {
      let str = ''
      switch (dataIndex) {
        case 'orderCode':
          str = '请输入工单编号'
          break
        case 'goodsName':
          str = '请输入产品名称'
          break
        case 'processName':
          str = '请输入工序名称'
          break
        case 'goodsSpec':
          str = '请输入规格'
          break
      }
      return str
    },
    pubSearch(confirm, dataIndex, clearFilters) {
      confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥11：', confirm)
      console.log('这都是啥22：', dataIndex)
      this.filterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      this.realFilterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      let params = this.formatData()
      this.current = 1
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      this.getData(obj)
      // console.log('这都是啥33：', clearFilters)
    },
    // table
    tableChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      let params = this.formatData()
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        let obj = {
          pageNo: this.current,
          pageSize: this.pageSize,
          ...params,
          sortType: sortType,
          sortColumn: sorter.columnKey,
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: sorter.columnKey,
        }
        this.getData(obj)
      } else {
        this.sortForm = {}
        let obj = {
          pageNo: this.current,
          pageSize: this.pageSize,
          ...params,
        }
        this.getData(obj)
      }
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      // console.log('第一个参数是；', selectedRowKeys)
      // console.log('第second个参数是；', selectedRows)
      this.selectedRowKeys = selectedRowKeys
      this.chooseArr = []
      for (let tag of selectedRowKeys) {
        for (let item of this.allRequestList) {
          if (tag == item.id) {
            this.chooseArr.push(item)
          }
        }
      }
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.tableData) {
          tableIds.push(item.id)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        console.log()
        console.log('第一个参数是；', checkValue)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 全选
    onCheckAllChange(e) {
      console.log('zhehsig', e.target)
      if (e.target.checked) {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
          this.chooseArr = this.chooseArr.filter((every) => {
            return every.id != item.id
          })
          this.selectedRowKeys.push(item.id)
          this.chooseArr.push(item)
        }
      } else {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
          this.chooseArr = this.chooseArr.filter((every) => {
            return every.id != item.id
          })
        }
      }
      this.checkBoxStatus()
    },
    clearArr() {
      this.selectedRowKeys = []
      this.chooseArr = []
      this.checkBoxStatus()
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      let params = this.formatData()
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      let secondParams = true
      this.getData(obj, secondParams)
    },
    onShowSizeChange(current, pageSize) {
      this.pageSize = pageSize
      this.current = 1
      let params = this.formatData()
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      let secondParams = true
      this.getData(obj, secondParams)
    },
    userOperator(storeVals, row) {
      console.log('这里限制性了')
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }
      if (newArr.length > 0) {
        this.tableFilterForm.operatorIds = newArr.join(',')
      } else {
        this.tableFilterForm.operatorIds = ''
      }
      if (arrTwo.length > 0) {
        this.showOperatorStr = arrTwo.join(',')
      } else {
        this.showOperatorStr = ''
      }
      this.filterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      this.realFilterForm = JSON.parse(JSON.stringify(this.tableFilterForm))
      let params = this.formatData()
      this.current = 1
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      this.getData(obj)
    },

    // 抽屉方法
    operatorChange(storeVals, row) {
      let newStr = ''
      if (row.length > 0) {
        let newArr = []
        let arrTwo = []
        for (let item of row) {
          newArr.push(item.id)
          arrTwo.push(item.realname)
        }
        if (newArr.length > 0) {
          newStr = newArr.join(',')
        }
        if (arrTwo.length > 0) {
          this.showOperatorStr = arrTwo.join(',')
        }
      } else {
        newStr = ''
        this.showOperatorStr = ''
      }
      this.$set(this.filterForm, 'operatorIds', newStr)
    },

    timeApplyChange(a, b) {
      if (!b[0] && !b[1]) {
        this.modelApplyTime = []
        this.filterForm.applyTime = []
      } else {
        this.filterForm.applyTime = b
      }
    },
    showDrawer() {
      this.showFilter = true
    },
    /* 确定筛选 */
    handleFilter() {
      console.log('当前选择的是：', this.filterForm)
      let params = this.formatData()
      this.current = 1
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      this.getData(obj)
      this.realFilterForm = JSON.parse(JSON.stringify(this.filterForm))
      this.tableFilterForm = JSON.parse(JSON.stringify(this.filterForm))
      this.showFilter = false
    },
    // 筛选传参数据
    formatData(v) {
      let copyForm = JSON.parse(JSON.stringify(this.filterForm))
      let params = {}
      params.orderCode = copyForm.orderCode
      params.goodsName = copyForm.goodsName
      params.goodsSpec = copyForm.goodsSpec
      params.processName = copyForm.processName
      params.operatorIds = copyForm.operatorIds
      if (copyForm.applyTime && copyForm.applyTime.length > 0) {
        params.applyTimeBegin = copyForm.applyTime[0] + ' ' + '00:00:00'
        params.applyTimeEnd = copyForm.applyTime[1] + ' ' + '23:59:59'
      } else {
        params.applyTimeBegin = ''
        params.applyTimeEnd = ''
      }
      if (copyForm.processIds && copyForm.processIds.length > 0) {
        params.processIds = copyForm.processIds.join(',')
      }
      if (v == 'export') {
        params.type = 'quality'
      }
      return params
    },
    /* 删除已选 */
    delFiltered(key) {
      if (this.filteredFormLable[key] == '操作人') {
        this.operatorStr = ''
        this.showOperatorStr = ''
        this.filterForm[key] = ''
      } else if (this.filteredFormLable[key] == '提交时间') {
        this.modelApplyTime = []
        this.filterForm[key] = []
      } else if (this.filteredFormLable[key] == '工序名称') {
        this.filterForm[key] = []
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        orderCode: '',
        goodsName: '',
        goodsSpec:'',
        processName: '',
        planStartTime: [],
        planEndTime: [],
        operatorIds: '',
        applyTime: [],
      }
      this.operatorStr = ''
      this.showOperatorStr = ''
      this.modelApplyTime = []
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    checkShow(item) {
      let currentBoolean = Array.isArray(item)
      if (currentBoolean) {
        if (item.length == 0) {
          return false
        } else {
          return true
        }
      } else {
        if (item) {
          return true
        } else {
          return false
        }
      }
    },
  },
}
</script>
<style scoped lang='less'>
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.table-operations {
  margin-bottom: 16px;
}

.table-operations > button {
  margin-right: 8px;
}
.topBox {
  .flex(space-between, center);
  margin-bottom: 16px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
.pubColor {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}
.pagebox {
  /deep/ .ant-card-body {
    height: calc(100vh - 214px);
    overflow: hidden;
    padding: 20px 16px;
  }
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
.modalTopBox {
  .flex(flex-start, center);
  margin-bottom: 8px;
  span {
    margin-left: 16px;
    display: block;
    overflow: hidden;
    color: rgba(0, 0, 0, 0.85);
    font-weight: 500;
    font-size: 16px;
    line-height: 1.4;
  }
}
.bigFont {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.78);
  box-sizing: border-box;
  padding-left: 12px;
  margin-bottom: 8px;
  font-weight: 600;
}
.smallFont {
  font-size: 14px;
  box-sizing: border-box;
  padding-left: 12px;
}

.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
</style>